package com.fanxuankai.ksql.function.udf.datetime;

import io.confluent.ksql.function.udf.Udf;
import io.confluent.ksql.function.udf.UdfDescription;
import io.confluent.ksql.function.udf.UdfParameter;

import java.sql.Date;
import java.sql.Time;

/**
 * @author fanxuankai
 */
@UdfDescription(name = "get_timestamp", description = "timestamp", author = "fanxuankai")
public class Timestamp {
    @Udf
    public java.sql.Timestamp calc(@UdfParameter("val") java.sql.Timestamp o) {
        return o;
    }

    @Udf
    public java.sql.Timestamp calc(@UdfParameter("val") Date o) {
        return o == null ? null : new java.sql.Timestamp(o.getTime());
    }

    @Udf
    public java.sql.Timestamp calc(@UdfParameter("val") Time o) {
        return o == null ? null : calc(new Date(o.getTime()));
    }
}
